package com.service;

import com.dao.userdao.Register;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/***
 * 注册时的一些信息验证和查重
 */
public class RegisterCheck {
    /***
     * 验证邮箱验证码
     */
    public static boolean check_code(String code, HttpServletRequest req){
        String mailbox=req.getParameter("mailbox");
        String str=mailbox.substring(0, mailbox.indexOf("@"));
        boolean resp=true;
       String rightcode= (String) req.getSession().getAttribute(str);
        if(rightcode.equals(code))
        {   req.getSession().removeAttribute(str);
        }else {
           resp=false;
        }
        return resp;
    }
    /***
     * 邮箱查重
     */
    public static boolean check_mailbox(String mailbox) throws IOException {
        boolean resp=true;
        resp= Register.check_agagin_mailbox(mailbox);
        return resp;
    }
}
